<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>${fns:getConfig('productName')}</title>
  <link rel="stylesheet" href="${ctxStatic}/layui-v2.5.6/layui/css/layui.css">
  <script type="text/javascript" src="${ctxStatic}/layui-v2.5.6/layui/layui.js"></script>

</head>


<body>

<div class="layui-fluid">
<div class="layui-card">
<div class="layui-form layui-card-header layuiadmin-card-header-auto" style="padding-top: 10px;padding-bottom: 10px;">
   	
  <div class="layui-form-item">
  <label class="layui-form-label">公司名称：</label>
	<div class="layui-input-inline" style="width: 160px;">
	     <input type="text" id="companyName" name="companyName" autocomplete="off" class="layui-input">
	</div>
	<label class="layui-form-label">车牌号:</label>
	<div class="layui-input-inline" style="width: 160px;">
	     <input type="text" id="vehicleNo" name="vehicleNo" autocomplete="off" class="layui-input">
	</div>
	
 <!--<button class="layui-btn layuiadmin-btn-comm" id="queryBtn" data-type="reload" lay-submit="" lay-filter="LAY-app-contcomm-search">
         <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
    </button> -->
    
     <button class="layui-btn layuiadmin-btn-comm" id="queryBtn" data-type="reload" lay-submit="" lay-filter="LAY-app-contcomm-search">
         <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
    </button>
  </div>
  
</div>
<div class="layui-card-body">
	<table id="table" lay-filter="test" class="demo-tree-more"></table>
</div>
</div>
</div>


<script type="text/html" id="toolbarDemo">
  <div class="layui-btn-container">
	
    	<button class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon layui-icon-add-1"></i>新增</button>
	
  </div>
</script>


<!-- 行工具栏 -->
<script type="text/html" id="barDemo">

      <a class="layui-btn layui-btn-xs layui-btn-normal btn-auth" lay-event="edit" ekper="web/disease/editDisease">编辑</a>
	  <a class="layui-btn layui-btn-xs layui-btn-normal btn-auth" lay-event="edit" ekper="web/disease/editDisease">查看</a>
      <a class="layui-btn layui-btn-xs layui-btn-danger btn-auth" lay-event="del" ekper="web/disease/deleteDisease">删除</a>


</script>


<script>
layui.use(['table','form','laydate'], function(){
  var table = layui.table;
  var form = layui.form; 
  var $ = layui.$;
  var laydate = layui.laydate;
  
  var firstDate = new Date();
  /* var entryTime = new entryTime(); */
/*   firstDate.setDate(1); //第一天
  var endDate = new Date(firstDate);
  endDate.setMonth(firstDate.getMonth()+1);
  endDate.setDate(0); */
  
 /*   laydate.render({
		elem: '#entryTime',
		trigger: 'click', //采用click弹出
		value: new Date(firstDate)
	}); */
	//日期
	/* laydate.render({
		elem: '#createDate',
		trigger: 'click', //采用click弹出
		value: new Date(endDate)
	});  */

  table.render({
	id: 'thisReloadId'
    ,elem: '#table'
    ,height: 650
    ,url:'${ctx}/jx/securityDriver/listByAjax'
     ,toolbar: '#toolbarDemo'  //开启头部工具栏，并为其绑定左侧模板
    ,defaultToolbar: ['filter', 'exports', 'print']
     ,title: '汽车管理' 
    ,totalRow:true//开启合计行
    ,cols: [[	 
             /*   {type:'id',title:'序号'}   */      
             	{field:'companyName', title:'公司名称',width:200}
             	 ,{field:'officeId', title:'机构ID', templet:'<div>{{d.office.id ? d.office.id : ""}}</div>',width:200} 
                  ,{field:'vehicleNo', title:'车牌号',width:200}
                   ,{field:'color', title:'车牌颜色',width:200} 
                   ,{field:'qualificationCertificate', title:'从业资格证',width:200}
                   ,{field:'issuingAuthority', title:'发证机构',width:200}
                   ,{field:'name', title:'司机名称',width:200}/* enterpriseCountyDistrict */
                   ,{field:'idCard', title:'身份证号码',width:200}
                   ,{field:'entryTime', title:'入职时间',templet : "<div>{{d.entryTime ? layui.util.toDateString(d.entryTime, 'yyyy-MM-dd') : ''}}</div>",width:200}
                   ,{field:'createById ', title:'创建者',width:200}
                   ,{field:'createdate', title:'创建时间',width:200}
                   ,{field:'updatebyId ', title:'更新者',width:200}
                   ,{field:'updateDate', title:'更新时间',templet : "<div>{{d.updateDate ? layui.util.toDateString(d.updateDate, 'yyyy-MM-dd') : ''}}</div>",width:200}
                   ,{field:'remarks', title:'备注',width:200}
                   ,{fixed: 'right', title:'操作', toolbar: '#barDemo',width:350}
                   
                   
                  /*  ,{field:'timeDate', title:'开始时间',width:200} */
                   /* ,{field:'timeDate', title:'登记日期', templet : "<div>{{d.timeDate ? layui.util.toDateString(d.timeDate, 'yyyy-MM-dd') : ''}}</div>",width:150} */
                  /*  ,{field:'oveTimeDate', title:'结束时间',width:200} */
                   /* ,{field:'oveTimeDate', title:'登记日期', templet : "<div>{{d.oveTimeDate ? layui.util.toDateString(d.oveTimeDate, 'yyyy-MM-dd') : ''}}</div>",width:150}
                   ,{field:'loans', title:'贷款期限',width:200}
                   ,{field:'premium', title:'是否有担保费',width:200}
                   ,{field:'state', title:'状态',width:200}
                   ,{field:'operation', title:'备注',width:200} */
			/*operation;  ,{fixed: 'right', title:'操作', toolbar: '#barDemo',width:150} */
                  
    ]]
    ,page: false
    ,done: function (res, curr, count) {
    	$(".layui-table th").css({"font-family":"黑体","font-size":"15","font-weight":"bold"});// 设定表格标题字体加粗
    }
  });
	
 /*  $('#queryBtn').on('click', function(){
	 var companyName  = $('#companyName').val();  
     var vehicleNo = $('#vehicleNo').val();
     
	 /*  alert("name value:"+name); 调试  
      //执行重载
      table.reload('thisReloadId', {
    	method : 'post',
        where: { //查询条件
        	vehicleNo: vehicleNo,
        	companyName:companyName  
        }
      });
  }); */
  $('#queryBtn').on('click', function(){
	  var companyName = $('#companyName').val();
      var vehicleNo = $('#vehicleNo').val();  
  		 /* alert("rent value:"+rent);   */
      //执行重载
      table.reload('thisReloadId', {
    	method : 'post',
        where: { //查询条件
        	companyName: companyName,
        	vehicleNo: vehicleNo  
        }
      });
        /*  alert("你好嘛! value:"+rent);   */
  }); 

  
  
  
  //头工具栏事件
  table.on('toolbar(test)', function(obj){
    var checkStatus = table.checkStatus(obj.config.id);
    data = checkStatus.data; //获取选中的数据
    switch(obj.event){
      case 'add':
        layer.open({
        	id:'1',
    		type: 2,
    	    title: '增加资产',
    	    btn: ['关闭'],
    	    yes: function(index, layero){
    	    	layer.close(index);
    	    },
    	    shadeClose: true,
    	    shade: false,
    	    area: ['893px', '650px'],
    	    content: '${ctx}/jx/securityDriver/form'
    	});
        
      break;
    };
  });
  //监听行工具事件
  table.on('tool(test)', function(obj){
    var data = obj.data;
    if(obj.event === 'del'){
      layer.confirm('真的删除该行么？', function(index){
        $.ajax({
            url: "${ctx}/jx/securityDriver/deleteById",
            type: "POST",
            dataType: "json",
            data: {
            	id : data.id
            },
            async: false,
            success: function(data){
                layer.close(index);
                /* var officeid={};
                officeid.id=data.field.officeid;
                data.field.officeid=officeid;
                var  aa JSON,stringfy(data.fieId); */
                //执行重载
                table.reload('thisReloadId', {
                  page: {
                    curr: 1 //重新从第 1 页开始
                  }
                }, 'data');
                layer.msg(data);
            },
            error: function(){
            	layer.msg('删除失败', {icon: 2});
            }
        });
      });
    }  else if(obj.event === 'edit'){
    	//iframe窗
    	layer.open({
    		id:'3',
    		type: 2,
    	    title: '编辑伙食支出',
    	    btn: ['关闭'],
    	    yes: function(index, layero){
    	    	layer.close(index);
    	    },
    	    shadeClose: true,
    	    shade: false,
    	    area: ['893px', '650px'],
    	    content: '${ctx}/jx/securityDriver/form?id='+data.id
    	});	
    } 
  });
  
  function timestampToTime(timestamp) {
	    var date = new Date(timestamp);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
	    var Y = date.getFullYear() + '-';
	    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
	    var D = date.getDate();
	    return Y + M + D;
  }
});
</script>
</body>
</html>